/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aaron.platform.entity;

import com.aaron.platform.view.FacesUtil;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 *
 * @author aaronbamboo
 */
@Entity
@Table(name = "wlb_motor_book")
@SequenceGenerator(name="WLB_MOTOR_BOOK_GENERATOR", sequenceName="WLB_MOTOR_BOOK_GENERATOR", allocationSize = 1)
public class WlbMotorBook extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;
    
    public final static String PROPERTY_MOTOR_ID = "wlbMotorInfo.motorId";
    
    public final static String PROPERTY_BOOK_ID = "bookId";
    
    public final static String PROPERTY_BOOK_DATE = "bookDate";
    
    public final static String PROPERTY_BOOK_DATE_FROM = "bookStartDate";
    
    public final static String PROPERTY_BOOK_DATE_TO = "bookEndDate";
    
    public final static String PROPERTY_BOOK_USER = "bookUsr";
    
    public final static int BOOK_STYLE_MORNING = 1;
    
    public final static int BOOK_STYLE_AFTERNOON = 2;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator="WLB_MOTOR_BOOK_GENERATOR")
    @Column(name = "book_id")
    private Integer bookId;
    
    /** 预约人 */
    @Column(name = "booker")
    private String booker;
    
    /** 预约使用日期 */
    @Column(name = "book_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date bookTime;
    
    /** 使用人 */
    @Column(name = "book_usr")
    private String bookUsr;
    
    /** 预约使用日期 */
    @Column(name = "book_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date bookDate;
    
    /** 预约时长(1:上午；2：下午；3：全天) */
    @Column(name = "book_style")
    private int bookStyle;
    
    /** 目的地 */
    @Column(name = "destination")
    private String destination;
    
    /** 事项说明 */
    @Column(name = "work_remark")
    private String workRemark;
    
    /** 对应的车辆信息 */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "motor_id", referencedColumnName = "motor_id")
    private WlbMotorInfo wlbMotorInfo;

    public Date getBookDate() {
        return bookDate;
    }

    public void setBookDate(Date bookDate) {
        this.bookDate = bookDate;
    }

    public Integer getBookId() {
        return bookId;
    }

    public void setBookId(Integer bookId) {
        this.bookId = bookId;
    }

    public int getBookStyle() {
        return bookStyle;
    }

    public void setBookStyle(int bookStyle) {
        this.bookStyle = bookStyle;
    }

    public String getBookUsr() {
        return bookUsr;
    }

    public void setBookUsr(String bookUsr) {
        this.bookUsr = bookUsr;
    }

    public String getDestination() {
        return destination;
    }

    public void setDestination(String destination) {
        this.destination = destination;
    }

    public WlbMotorInfo getWlbMotorInfo() {
        return wlbMotorInfo;
    }

    public void setWlbMotorInfo(WlbMotorInfo wlbMotorInfo) {
        this.wlbMotorInfo = wlbMotorInfo;
    }

    public String getWorkRemark() {
        return workRemark;
    }

    public void setWorkRemark(String workRemark) {
        this.workRemark = workRemark;
    }

    public Date getBookTime() {
        return bookTime;
    }

    public void setBookTime(Date bookTime) {
        this.bookTime = bookTime;
    }

    public String getBooker() {
        return booker;
    }

    public void setBooker(String booker) {
        this.booker = booker;
    }
    
    public String getDisplayBookStyle() {
        if (bookStyle == WlbMotorBook.BOOK_STYLE_MORNING) 
            return FacesUtil.getString("table_column_motor_morning");
        else if (bookStyle == WlbMotorBook.BOOK_STYLE_AFTERNOON) 
            return  FacesUtil.getString("table_column_motor_afternoon");
        else
            return "";
    }
}
